<?php
class VC{
	public function __construct($conf="")
	{
		if($conf!="")
		{
			foreach($conf as $key=>$value)
			{
				$this->$key=$value;
			}
		}
	}
	public static function show(){
		Header("Content-type: image/jpg");
		$fontsize = 5;
		$alpha = "abcdefghijkmnpqrstuvwxyz";
		$number = "23456789";
		$randcode = "";
		$im = ImageCreate(100,20);
		$bgcolor = ImageColorAllocate($im,255,255,255);
		imagefill($im,0,0,$bgcolor);
		$black = ImageColorAllocate($im,0,0,0);
		imagerectangle($im, 0, 0, 100-1, 20-1, $black);
		for($i=0; $i<6; $i++)
		{
			$alpha_or_number = mt_rand(0, 1);
			$str = $alpha_or_number ? $alpha : $number;
			$which = mt_rand(0, strlen($str)-1);
			$code = substr($str, $which, 1);
			$j = !$i ? 4 : $j+15;
			$color3 = ImageColorAllocate($im,mt_rand(0,100),mt_rand(0,100),mt_rand(0,100));
			imagechar($im,$fontsize,$j,3,$code,$color3);
			$randcode .= $code;
		}
		for($i=0;$i<5;$i++)
		{
			$color1 = imagecolorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
			imagearc($im,mt_rand(-5,100),mt_rand(-5,20),mt_rand(20,300),mt_rand(20,200),55,44,$color1);
		}
		for($i=0;$i<6*15;$i++)
		{
			$color2 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
			ImageSetPixel($im, mt_rand(0,100), mt_rand(0,20), $color2);
		}
		Imagejpeg($im);
		ImageDestroy($im);
		return $randcode;
	}
}
$valicode = VC::show();
@session_start();
$_SESSION["valicode"] = $valicode;
?>